import java.io.File; 
import java.io.FileWriter; 
import java.io.IOException; 
import java.io.PrintWriter; 
import java.io.FileReader; 


public class highscore
{
	
	
	String highscoreFile ="highscore.txt";
	
	public void readHighscore()
	{
		File file = new File(highscoreFile); 

        if (!file.canRead() || !file.isFile()) 
            System.exit(0); 

        FileReader fr = null; 
        int c; 
        StringBuffer buff = new StringBuffer(); 
        try { 
            fr = new FileReader(file); 
            while ((c = fr.read()) != -1) { 
                buff.append((char) c); 
            } 
            fr.close(); 

        } catch (IOException e) { 
            e.printStackTrace(); 
        } 

        System.out.println(buff.toString()); 
	}
	
	public void saveHighscore(String playername, int tries)
	{
	PrintWriter pWriter = null; 
        try { 
            pWriter = new PrintWriter(new FileWriter(highscoreFile, true), true);
        pWriter.println("Spielername:\t"+playername+"\tVersuche:\t"+tries+"\n"); 
        } catch (IOException ioe) { 
            ioe.printStackTrace(); }
		
		System.out.println("Highscore saved!");		 

	}
}